


function validator(rules){

    return async (ctx,next)=>{
        try{
            ctx.verifyParams(rules)
        }catch(error){
            console.log(error)
            ctx.app.emit('error',{
                code:40000,
                message:"数据有误"+error,
                result:""
            },ctx)
        }
        await next()
    }
}


module.exports={
    validator
}